package com.example.threadmodel.utils;

import cn.hutool.extra.spring.SpringUtil;
import com.example.threadmodel.model.Action;
import com.example.threadmodel.service.ThreadManagerService;

import java.util.concurrent.Callable;

public class ActionUtil {

    public static <V> V runWithReturn(String queueId, Callable<V> callable) {
        Action<V> action = new Action<>(queueId, callable);

        SpringUtil.getBean(ThreadManagerService.class).enqueueAction(action);

        return action.get();
    }
}
